import { createRouter, createWebHistory } from 'vue-router';
import Index from '@/pages/index/Index.vue'
import Layout from '@/layout/Index.vue'
const routes = [

    {
        path: '/',
        component: Layout,
        redirect: '/index',
        children: [
            {
                path: '/index',
                name: 'index',
                component: Index,
                meta: {title: '首页', role: '', hide: false, key: 0}
            },
            {
                path: '/admin',
                name: 'admin',
                component: () => import('@/pages/admin/Index.vue'),
                meta: {title: '后台管理', role: 'admin', hide: false, key: 1}
            },
            {
                path: '/detail/:id',
                name: 'detail',
                component: () => import('@/pages/index/Detail.vue'),
                meta: {title: '详情', role: '', hide: true, key: 2}
            },
            {
                path: '/search',
                name: 'search',
                component: ()=> import('@/pages/search/Index.vue'),
                meta: {title: '搜索', role: '', hide: true, key: 3}
            }
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/login/Index.vue'),
        meta: {title: '登录', role: '', hide: true}
    },
    {
        path: '/regis',
        name: 'regis',
        component: () => import('@/pages/regis/Index.vue'),
        meta: {title: '注册', role: '', hide: true}
    }

];

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes
});

export default router;
